//
//  MYGPersionGrowViewController.swift
//  MYDoctor
//
//  Created by Denny on 2024/4/19.
//

import UIKit


class MYGPersionGrowViewController: MYGBaseController {
    var dataSource = [MYGIndustryExchangesData]()
    lazy var tableView:UITableView = {
        let control = UITableView()
        control.showsVerticalScrollIndicator = false
        control.dataSource = self
        control.rowHeight = 87
        control.delegate = self
        control.separatorStyle = .none
        control.backgroundColor = .clear
        control.register(UINib.init(nibName: "MYGMYGIndustryExchangesCell", bundle: nil), forCellReuseIdentifier: "MYGMYGIndustryExchangesCell")
        return control
    }()
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "个人成长"
        self.view.backgroundColor = UIColor.init(hexString: "#F5F6F8")
        view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(8)
            make.left.right.bottom.equalToSuperview()
        }
        var obj1 = MYGIndustryExchangesData()
        obj1.imageName = "MYG_icon_myreport"
        obj1.title = "我的报道"
        self.dataSource.append(obj1)
        
        var obj2 = MYGIndustryExchangesData()
        obj2.imageName = "MYG_icon_myResue"
        obj2.title = "完美简历"
        self.dataSource.append(obj2)
    
    }
}

extension MYGPersionGrowViewController: UITableViewDataSource,UITableViewDelegate {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataSource.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "MYGMYGIndustryExchangesCell", for: indexPath) as! MYGMYGIndustryExchangesCell
        let model = self.dataSource[indexPath.row]
        cell.titleLB.text = model.title
        cell.icon.image = UIImage(named: model.imageName)
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if indexPath.row == 0 {
            if ((MYGUserManager.getUser()?.doctor.name.isEmpty) == true) || MYGUserManager.getUser()?.doctor.gender == 0 || ((MYGUserManager.getUser()?.doctor.identity.isEmpty) == true) {
                let vc = MYGBaseInfoController()
    //            vc.model = model
                self.navigationController?.pushViewController(vc)
                return
            }
            
            if MYGUserManager.isDoctorInfComplete  {
                if MYGUserManager.getUser()?.doctor.status == 20 {
                    let vc = MYGMyReportsNewViewController()
                    self.navigationController?.pushViewController(vc, animated: true)
                }else {
                    MMYGHUD.showToast(text: "正在审核中，暂时无法使用该功能")
                }
        
            }else {
                let vc = MYGUpdateInfoViewController()
                vc.model = MYGUserManager.getUser()!
                vc.isEdit = true
                self.navigationController?.pushViewController(vc)
            }

        }
        if indexPath.row == 1 {
            let vc = MYGResumeViewController()
            self.navigationController?.pushViewController(vc, animated: true)
        }
        
    }
}
